package com.pzh.assignment.common.bean.vo;

import com.pzh.assignment.common.bean.GlobalConstant;
import com.pzh.assignment.entity.Groups;
import lombok.Data;

import java.time.format.DateTimeFormatter;


@Data
public class GroupsVO {
    private Integer id;

    private String name;

    private Integer collegeId;

    private String createTime;

    private String updateTime;

    public static GroupsVO valueOf(Groups groups) {
        GroupsVO vo = new GroupsVO();
        vo.setId(groups.getId());
        vo.setName(groups.getName());
        vo.setCollegeId(groups.getCollegeId());
        if (groups.getCreateTime() != null) {
            vo.setCreateTime(groups.getCreateTime().format(DateTimeFormatter.ofPattern(GlobalConstant.DATE_FORMAT_PATTERN)));
        }
        if (groups.getUpdateTime() != null) {
            vo.setUpdateTime(groups.getUpdateTime().format(DateTimeFormatter.ofPattern(GlobalConstant.DATE_FORMAT_PATTERN)));
        }
        return vo;
    }
}
